package com.dex4d.ui.mine.activity;

import android.view.View;

import com.dex4d.R;
import com.dex4d.constants.AppConstants;
import com.dex4d.core.AppToolBarBaseActivity;
import com.dex4d.ui.demo.HomeActivity;
import com.dex4d.utils.SPUtil;
import com.dex4d.widgets.SimpleListItem;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by chengyuchun on 2018/11/2.
 */
public class SettingCurrencyActivity extends AppToolBarBaseActivity {

    @BindView(R.id.sli_usd)
    SimpleListItem sli_usd;

    @BindView(R.id.sli_cny)
    SimpleListItem sli_cny;
    @Override
    protected void initToolbar() {
        showBackView();
        showTitle(getString(R.string.mine_currency));
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_setting_currency;
    }

    @Override
    protected void initVariables() {
        sli_usd.setArrowIcon(R.drawable.ic_selected);
        sli_cny.setArrowIcon(R.drawable.ic_selected);


        String currencyType = SPUtil.getString(AppConstants.SP_CURRENCY_KEY,"usd");
        if(currencyType.equalsIgnoreCase("usd")){
            sli_usd.setArrowDisplay(true);
            sli_cny.setArrowDisplay(false);
        }else if(currencyType.equalsIgnoreCase("cny")){
            sli_usd.setArrowDisplay(false);
            sli_cny.setArrowDisplay(true);
        }
    }

    @OnClick({R.id.sli_usd,R.id.sli_cny})
    public void onViewClick(View view){
        switch (view.getId()){
            case R.id.sli_usd:
                sli_usd.setArrowDisplay(true);
                sli_cny.setArrowDisplay(false);
                SPUtil.putString(AppConstants.SP_CURRENCY_KEY,"usd");
                break;
            case R.id.sli_cny:
                sli_usd.setArrowDisplay(false);
                sli_cny.setArrowDisplay(true);
                SPUtil.putString(AppConstants.SP_CURRENCY_KEY,"cny");
                break;
        }
        openActivity(HomeActivity.class);
    }

    @Override
    protected void loadData() {

    }
}
